package cn.com.dstz.agent.config;

import java.util.Map;

public class AnalysisConfig extends AgentConfig{
	
	public AnalysisConfig( ){}
	
	public AnalysisConfig( Map< String, Object > admin, int count ){
		super( admin, count, AgentConfig.CONFIG_ANALYSIS );
	}
	
	@Override
	public String getSQL( ) {
		
		if( this.getReturnValue( ).equals( SELF )){
			valueMap.put( "aid", admin.get( "id" ) );
			return " and f.adminid =:aid ";
		}else if( this.getReturnValue( ).equals( ALL ) ){
			valueMap.put( "aid", admin.get( "topaid" ) );
			return " and f.aid = :aid ";
		}
		
		valueMap.put( "topaid", admin.get( "topaid" ) );
		valueMap.put( "adminid", admin.get( "id" ) );
		
		return getDefinedSQL( );
	}

	@Override
	public String getDefinedSQL( ) {
		String beginSQL = " and ( f.adminid in ( select id from dstzadmin where";
		String endSQL = " and topaid=:topaid ) or f.adminid=:adminid )";
		return beginSQL + super.getDefinedSQL( ) + endSQL;
		//return " and topaid=:topaid";
	}
	
	
	

}
